package com.demo.web.Config;

import com.demo.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.LinkedList;


@Configuration
public class MyWebAppConfigurer implements WebMvcConfigurer {

   @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //账户登录验证的拦截器
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/api/backstage/**")//拦截的
                .excludePathPatterns(new LinkedList<String>(){{
                    add("/api/backstage/index/Login");
                    add("/api/backstage/register");
                    add("/api/backstage/hello");
                    add("/api/backstage/user1");
                    add("/api/backstage/user2");
                    add("/api/backstage/user3");
                    add("/api/backstage/user3");
                    add("/api/test/**");
                }});
    }
}
